package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkSpaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 * 工作台相关接口
 */
@RestController
@RequestMapping("/admin/workspace")
@Slf4j
@Api(tags = "工作台相关接口")
public class WorkSpaceController {

    @Autowired
    private WorkSpaceService workSpaceService;

    /**
     * 查询套餐总览
     * @return
     */
    @GetMapping("/overviewSetmeals")
    @ApiOperation("查询套餐总览")
    public Result overviewSetmeals() {
        log.info("查询套餐总览");
        SetmealOverViewVO setmealOverViewVO = workSpaceService.overviewSetmeal();
        return Result.success(setmealOverViewVO);
    }

    /**
     * 查询菜品总览
     * @return
     */
    @GetMapping("/overviewDishes")
    @ApiOperation("查询菜品总览")
    public Result overviewDishes() {
        log.info("查询菜品总览");
        DishOverViewVO dishOverViewVO = workSpaceService.overviewDish();
        return Result.success(dishOverViewVO);
    }

    /**
     * 查询订单总览
     * @return
     */
    @GetMapping("/overviewOrders")
    @ApiOperation("查询订单总览")
    public Result overviewOrders(){
        log.info("查询订单总览");
        OrderOverViewVO orderOverViewVO = workSpaceService.overview();
        return Result.success(orderOverViewVO);
    }

    /**
     * 查询今日运营数据
     * @return
     */
    @GetMapping("/businessData")
    public Result getBusinessData(){
        log.info("查询今日运营数据");
        // 设置查询开始时间
        LocalDateTime begin = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
        // 设置查询结束时间
        LocalDateTime end = LocalDateTime.now().withHour(23).withMinute(59).withSecond(59);
        BusinessDataVO businessDataVO = workSpaceService.getBusinessData(begin, end);
        return Result.success(businessDataVO);
    }
}
